package com.fmdrama.test;

import java.net.URL;
import java.net.URLEncoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;

import com.fmdrama.util.GZIPUtil;

public class Detail {
	
	public static void main(String[] args) {
		HttpClient client = new HttpClient();
		PostMethod getMethod = null;
		try{
			//http://share.vrs.sohu.com/1442477/v.swf&topBar=1&autoplay=false&plid=5943121&pub_catecode=&from=page
			//http://share.vrs.sohu.com/1364906/v.swf&topBar=1&autoplay=false&plid=5943121&pub_catecode=&from=page
			//http://share.vrs.sohu.com/my/v.swf&autoplay=false&id=63561124&skinNum=1&topBar=1&xuid=
			String url = "http://www.koreayh.com/play/3356";
			getMethod = new PostMethod(url);
			client.executeMethod(getMethod);
			String result = getMethod.getResponseBodyAsString();
			parse(result);
//			System.out.println(result);
		}catch (Exception e) {
			e.printStackTrace();
		}finally{
			getMethod.releaseConnection();
		}
	}
	
	public static void parse(String source){
		Pattern pattern = Pattern.compile("<a class=\"(.*?)\" title=\"(.*?)\" href=\"javascript:;\" data-index=\"(.*?)\" data-count=\"(.*?)\" data-id=\"(.*?)\"></a>");
		Pattern p = Pattern.compile("<span class=\"view_img\">([\\s\\S]*?)</span>");
		Matcher m = p.matcher(source);
		while(m.find()){
			String sub = m.group(0);
			Matcher matcher = pattern.matcher(sub);
			System.out.println("");
			while(matcher.find()){
				System.out.println(matcher.group(1) + " : " + matcher.group(2) + " : "  + matcher.group(3) + " : " + matcher.group(4)+ " : " + matcher.group(5));
			}
		}
	}
	
}
